package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.adminOrderService;
import com.sky.vo.OrderStatisticsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "完成订单相关接口")
@RequestMapping("/admin/order")
@RestController
public class OrderController {
    @Autowired
    private adminOrderService adminOrderService;

    /**
     * 完成订单功能
     *
     * @param id
     * @return
     */
    @ApiOperation("完成订单")
    @PutMapping("/complete/{id}")
    public Result completeOrder(@PathVariable Long id) {
        log.info("完成订单:{}", id);
        adminOrderService.completeOrder(id);
        return Result.success();
    }

    /**
     * 各个状态订单数量统计
     */
    @ApiOperation("订单数量统计")
    @GetMapping("/statistics")
    public Result<OrderStatisticsVO> orderCount() {
        log.info("订单数量显示:");
        OrderStatisticsVO orderStatisticsVO=adminOrderService.ordercount();
        return Result.success(orderStatisticsVO);
    }

}
